package com.example.order.event;

import java.math.BigDecimal;
import java.time.LocalDateTime;

public class OrderPaidEvent extends OrderEvent {
    private final String paymentMethod;
    private final BigDecimal amount;
    private final LocalDateTime createTime;

    public OrderPaidEvent(Object source, String orderNo, String paymentMethod, 
                         BigDecimal amount, LocalDateTime createTime) {
        super(source, orderNo);
        this.paymentMethod = paymentMethod;
        this.amount = amount;
        this.createTime = createTime;
    }

    public String getPaymentMethod() {
        return paymentMethod;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    // 计算支付耗时（秒）
    public long getPaymentDurationSeconds() {
        return java.time.Duration.between(createTime, LocalDateTime.now()).getSeconds();
    }
}
